local kuisi = fk.CreateSkill{
  name = "mod__kuisi",
  frequency = Skill.Compulsory,
}
local U = require "packages/utility/utility"
local kuisi_ = {
  anim_type = "special",
  can_trigger = function(self, event, target, player, data)
    return target == player and player:hasSkill(self) and player.phase == Player.Draw
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local used = {}
    local to_use = {}
    for i = 1, 4 do
      if room.draw_pile[i] then
        table.insertIfNeed(to_use, room.draw_pile[i])
      end
    end
    while not player.dead and #to_use > 0 do
      local use = U.askForUseRealCard(room, player, to_use, ".|.|.|^hand", self.name, nil, {expand_pile = to_use}, true)
      if use then
        table.removeOne(to_use, use.card:getEffectiveId())
        table.insertIfNeed(used, use.card:getEffectiveId())
        room:useCard(use)
        for _, id in ipairs(to_use) do
          if id then
            if room:getCardArea(id) ~= Player.Hand and room:getCardArea(id) ~= Player.Equip
            and room:getCardArea(id) ~= Card.DrawPile and room:getCardArea(id) ~= Card.DiscardPile then
              table.removeOne(to_use, id)
            end
          end
        end
      else
        break
      end
    end
    if #used ~= 2 and #used ~= 3 then
      room:changeMaxHp(player, -1)
    end
    return true
  end,
}
kuisi:addEffect(fk.EventPhaseStart, kuisi_)
return kuisi